<?php

namespace app\admin\controller;

use support\Request;
use app\common\Attribute;
use app\common\View;
use app\model\Config;

#[Attribute(title: "系统配置")]
class ConfigController
{
    #[Attribute(isAuth: true, isPage: true, title: "网站配置")]
    public function base(Request $request)
    {
        $find = Config::select("prefix", $request->action);
        View::assign("find", $find);
        if ($request->method() == "POST") {
            $all = $request->all();
            $res = Config::saves($all, $request->action);
            if ($res) {
                return success("操作成功");
            } else {
                return error("操作失败");
            }
        }
        return View::fetch();
    }
}
